package cn.demo.service1.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;

/**
 * @Author: ljh
 * @Date: 2019/10/31 20:28
 */
@Configuration
public class ResourceServerConfiguration extends ResourceServerConfigurerAdapter {

    @Override
    public void configure(HttpSecurity http) throws Exception {
        //所有的访问规则都是通过传入的HttpSecurity进行配置
        //现在配置对所有的访问进行控制
        //http.authorizeRequests().anyRequest().authenticated();
        //角色限制
        http.authorizeRequests().antMatchers("/test")
                .hasAnyRole("ADMIN").anyRequest().authenticated();

    }
}
